﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace Matrix.Common.Utility
{
    public class JsonModel
    {
        [Serializable]
        [DataContract(Name = "PageList_Using_{0}", Namespace = "Matrix.Common.Utility.JsonModel")]
        public class PageList<T>
        {
            public PageList(List<T> rowList, int rowCount)
            {
                rows = rowList;
                total = rowCount;
            }
            /// <summary>
            /// 数据集List
            /// </summary>
            [DataMember(Name = "rows")]
            [Display(Name = "数据集List")]
            public List<T> rows { get; set; }

            /// <summary>
            /// 数据总条数
            /// </summary>
            [DataMember(Name = "total")]
            [Display(Name = "数据总条数")]
            public int total { get; set; }
        }

        /// <summary>
        /// 执行结果
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public class ExecResult<T>
        {
            /// <summary>
            /// 执行成功与否
            /// </summary>
            [DataMember(Name = "result")]
            [Display(Name = "执行成功与否")]
            public bool result { get; set; }

            /// <summary>
            /// 返回内容
            /// </summary>
            [DataMember(Name = "msg")]
            [Display(Name = "返回内容")]
            public string msg { get; set; }

            /// <summary>
            /// 返回对象
            /// </summary>
            [DataMember(Name = "obj")]
            [Display(Name = "返回对象")]
            public T obj { get; set; }
        }

        public class ExecResultSimple
        {
            /// <summary>
            /// 执行成功与否
            /// </summary>
            [DataMember(Name = "result")]
            [Display(Name = "执行成功与否")]
            public bool result { get; set; }

            /// <summary>
            /// 返回内容
            /// </summary>
            [DataMember(Name = "msg")]
            [Display(Name = "返回内容")]
            public string msg { get; set; }
        }
    }
}
